#!/usr/local/bin/python3
# -*- coding: utf-8 -*-

"""
@File    : cross_group.py
@Author  : different && 道阻且长,行则将至 行而不辍,未来可期
@Time    : 2021/10/21 11:06
@Desc    : 交叉表分组模型

"""
from expand import db


class CrossAttr(db.Model):
    __tablename__ = 'data_cross_attr'
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    attr_name = db.Column(db.String(255), comment='属性名')
    is_main_attr = db.Column(db.Boolean, default=False, comment='是否为主属性')
    attr_group = db.relationship('CrossAttrGroup', cascade='all')
    table_id = db.Column(db.Integer, db.ForeignKey('data_source_title.id'), comment='关联到表')


class CrossAttrGroup(db.Model):
    __tablename__ = 'data_cross_attr_group'
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    lower_bound = db.Column(db.String(255), comment='区间下界(min)')
    upper_bound = db.Column(db.String(255), comment='区间上界(max)')
    cross_attr_id = db.Column(db.Integer, db.ForeignKey('data_cross_attr.id'), comment='属性关联')
